<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link href="__ROOT__/Public/admin/css/style.css" rel="stylesheet">
<link href="__ROOT__/Public/admin/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="__ROOT__/Public/plugin/editor/themes/default/default.css" />
<link href="__ROOT__/Public/plugin/select2/select2.css" rel="stylesheet">
<script charset="utf-8" src="__ROOT__/Public/plugin/editor/kindeditor.js"></script>
<script charset="utf-8" src="__ROOT__/Public/plugin/editor/lang/zh_CN.js"></script>
<script charset="utf-8" src="__ROOT__/Public/js/jquery.min.js"></script>
<title>{$title}</title>
</head>
<style>
        #imgList{
            max-width:510px;
        }
        #imgList .imgBox{
            width:160px;
            height:100px;
            position:relative;
            float:left;
            overflow:hidden;
            border:1px solid #ccc;
            margin-right:5px;

        }
        .imgBox img{
            width:156px;
            height:96px;
            margin:2px 2px;
        }
        .close_icon{
            position:absolute;
            cursor:pointer;
            right:0px;
            top:-5px;
            color:#666;
            display:none;
            font-size:14px;
        }
        .borders{
            position:relative;
            width:400px;
            height:20px;
        }
        .borders div,.borders span{
            display:inline-block;
        }
    </style>
    
<body>
    <div class="breadNav">
          <ul class="breadNavBar">
              <li><i class="icon-home" style="font-size:16px"></i></li>
              <li><a href="javascript:;" onClick="parent.location.reload('/Admin/Main/index');">首页</a></li>
              <li>&gt;</li>
              <li>二级分类列表</li>
           
          </ul>
    </div>
    <div style="clear:both;"></div>
    <div class="filter">
        <a href="javascript:history.go(-1);" class="btn btn-primary btn-lg" id="backBtn"><i class="icon-reply"></i>&nbsp;返回</a>
    </div>
    <form class="from">
        <div class="form-group" style="float:left">
			        <label class="control-label">绝密点题广告图片:</label>
			        <img id="diantiAds" width="156" height="96" style="margin:2px;" src='<if condition="$diantiAds eq ''">/Public/admin/nopic/nopic120x120.gif<else />{$diantiAds}</if>'>
			        <input type="hidden" id="diantiCover" name="diantiAds" class="form-control disBlock" value="{$diantiAds}" style="width:300px;">
			        <button type="button" id="diantiAds_btn" class="btn btn-primary disBlock"><i class="icon-plus"></i>&nbsp;图片</button>
			        <span class="helpBlock disBlock">图片建议尺寸：宽390像素、高480像素，图片最大不超过1M</span>
       	</div>      
          <div class="form-group" >
			        <label class="control-label">资料文库广告图片:</label>
			        <img id="wenkuAds" width="156" height="96" style="margin:2px;" src='<if condition="$wenkuAds eq ''">/Public/admin/nopic/nopic120x120.gif<else />{$wenkuAds}</if>'>
			        <input type="hidden" id="wenkuCover" name="wenkuAds" class="form-control disBlock" value="{$wenkuAds}" style="width:300px;">
			        <button type="button" id="wenkuAds_btn" class="btn btn-primary disBlock"><i class="icon-plus"></i>&nbsp;图片</button>
       	</div> 
        
        <!--<div class="form-group">-->
            <!--<label class="control-label">显示状态:</label>-->
            <!--<select id="isShow" name="isShow" class="form-control form-select" style="">-->
                <!--<option value="0">请选择显示状态</option>-->
                <!--<option value="1">是</option>-->
                <!--<option value="2">否</option>-->
            <!--</select>-->
            <!--<span class="helpBlock"></span>-->
        <!--</div>                                          -->
        <div class="form-group">
            <label class="control-label">&nbsp;</label>
            <input type="hidden" name="id" value="{$id}" />
            <button  class="btn btn-primary" id='sub'><i class='icon-check'></i>&nbsp;保存</button>
        </div>    
    </form>
</body>
<!-- <script src="__ROOT__/Public/js/jquery.min.js?ver=1.8.3"></script> -->
<!-- <script src="__ROOT__/Public/admin/js/main.js"></script> -->
<!-- <script src="__ROOT__/Public/js/vali.js"></script> -->
<script>
// $(document).ready(function(){
// 	$("#isShow").val("{$categoryInfo.isShow}");
// 	$("form").vali({
// 		"control":[
// 			{"id":"catName","rule":"notNull","errorText":""}
// 		]
// 	})
// });
</script>

<script>
$('#sub').click(function() {
	
	   var d=$("form").serialize();
	   $.post("__ROOT__/Admin/YatiAds/save",d,function(data)
			   {
		        alert(data);
				   })
           .error(function() { alert("请求出错"); });		
	return false;
 	  
});
   KindEditor.ready(function(K) {
        var editorgoodsCover = K.editor({
            basePath: '__ROOT__/Public/plugin/editor/'
            ,uploadJson : '__ROOT__/Public/plugin/fileup/upload_json.php?type=image&m=pic_Ads'
            ,fileManagerJson : '__ROOT__/Public/plugin/fileup/file_manager_json.php?type=image&m=pic_Ads'
            ,allowFileManager:true
        });
        K('#diantiAds_btn').click(function() {
            editorgoodsCover.loadPlugin('image', function() {
                editorgoodsCover.plugin.imageDialog({
                    imageUrl : K('#diantiCover').val(),
                    clickFn : function(url, title, width, height, border, align) {
                        K('#diantiCover').val(url);
                        $('#diantiAds').attr('src',url);
                        editorgoodsCover.hideDialog();
                    }
                });
            });
        });
        
        K('#wenkuAds_btn').click(function() {
            editorgoodsCover.loadPlugin('image', function() {
                editorgoodsCover.plugin.imageDialog({
                    imageUrl : K('#wenkuCover').val(),
                    clickFn : function(url, title, width, height, border, align) {
                        K('#wenkuCover').val(url);
                        $('#wenkuAds').attr('src',url);
                        editorgoodsCover.hideDialog();
                    }
                });
            });
        });

      
    });
    // $(document).ready(function(){
    //     $('#brandID,#catID').select2();
    //     $("form").vali({
    //         "control":[
    //             {"id":"goodsName","rule":"notNull","errorText":""},
    //             {"id":"brandID","rule":"notNull","errorText":""},
    //             {"id":"catID","rule":"notNull","errorText":""},
    //             {"id":"supplierID","rule":"notNull","errorText":""},
    //             {"id":"goodsCover","rule":"notNull","errorText":"请上传封面图片"},
    //             {"id":"goodsImages","rule":"notNull","errorText":"请至少上传一张图片"},
    //             {"id":"price","rule":"notNull","errorText":""},
    //             {"id":"mprice","rule":"notNull","errorText":""},
    //             {"id":"isSale","rule":"notNull","errorText":""},
    //             {"id":"isCheck","rule":"notNull","errorText":""},
    //             {"id":"state","rule":"notNull","errorText":""}

    //         ]
    //     })
    //     var jsons = $("#goodsImages").val().split(",");
    //     drawPhoto(jsons);
    //     var i =4;

    //     $("#imgList").on("mouseover",".imgBox",function(){
    //         $(this).find(".close_icon").show();
    //     }).on("mouseout",function(){
    //         $(this).find(".close_icon").hide();
    //     })
    //     $("#imgList").on("click",".close_icon",function(){
    //         $(this).parents(".imgBox").remove();
    //         var tempStr = $("#goodsImages").val().replace($(this).siblings("img").attr("src")+",","");
    //         $("#goodsImages").val(tempStr);
    //     })
    //     $(".imgBox").on("click",function(){
    //         var url = $(this).find("img").attr("src");
    //         if(confirm("是否设置为封面图片")){
    //             $("#goodsCoversrc").attr("src",url);
    //             $("#goodsCover").val(url);
    //         }
    //     })
    // });
    function drawPhoto(jsons){
        if(jsons.length>1){
            $("#imgList").html("");
        }
        for(var i =0;i<jsons.length-1;i++){
            $("#imgList").append("<div class='imgBox'><div class='close_icon'><i class='icon-remove-sign'></i></div><img src='"+jsons[i]+"'></div>");
        }

    }
</script>

</html>
